home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 338_01 / bc2.c < prev    next >
Text File  |  1988-02-23  |  2KB  |  65 lines

  1. /* bc2.c, code building function of as68 assembler (pass2 routines)
  2.  * 
  3.  *    (C) Copyright 1982 Steve Passe
  4.  *    All Rights Reserved
  5.  *
  6.  * version 1.00
  7.  * created 10/21/82
  8.  *
  9.  * version 1.01
  10.  *
  11.  *   8/30/83 ver. 1.01 modified for Aztec ver. 1.05g smp
  12.  *   10/12/87  split into root, pass1 and pass2 parts for overlay on pdp-11
  13.  */
  14.  
  15. /* begincode */
  16.  
  17. /* includes */
  18.  
  19. #include <stdio.h>
  20. #include "as68.h"
  21.  
  22. /* externals */
  23.  
  24. extern char pass;                /* present pass number, 1 or 2 */
  25. extern unsigned    line_count;            /* line number of source file */
  26. extern long loc_counter;            /* address to assemble obj code */
  27. extern int loc_plus;                /* increment to loc counter    */
  28. extern FLAG abs_long;                /* default to absolute long add.*/
  29. extern FLAG rorg;                /* in pc relative mode */
  30. extern char label[32];            /* buffer for label from preparse */
  31. extern char instr[33];            /* buffer for mnem, psdo or macro */
  32.  
  33. extern struct _mtable mtable[];            /* mnemonic    lookup table */
  34. extern struct _mvalue mvalue[];            /* mnemonic    code table */
  35. extern struct _oprnd op1, op2;          /* structs to hold operand val */
  36. extern char code[];                /* code array */
  37.  
  38. p2_mnem(mt)
  39. struct _mtable *mt;
  40. {
  41.     register int x;                     /* scratch */
  42.     register int index;                   /* index to mvalue */
  43.     register int result;
  44.  
  45.     for (x = 0; x < 10; ++x) {      /* init code array to 0 */
  46.     code[x]    = 0;
  47.     }
  48.     if ((index = match(mt)) == ERROR) {
  49.     dump_code(CODE,    code, 0);
  50.     return ERROR;
  51.     }
  52.     code[0] = mvalue[index]._opcb1;                /* get opcode */
  53.     code[1] = mvalue[index]._opcb2;                /* get opcode */
  54.  
  55.     if ((result    = (*mvalue[index]._p2_action)()) < 0) {     /* call funct */
  56.     err_out(result);
  57.     loc_plus = 0;
  58.     }
  59.     else loc_plus = ++result * 2;            /* bytes created */
  60.     dump_code(CODE, code, loc_plus);            /* send them */
  61.     return result;                    /* words created */
  62. }
  63.  
  64.  
  65.